package com.hsy.linemoney.modules.main.actionbar;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import com.hsy.linemoney.R;
import com.hsy.linemoney.modules.main.MainActivity;
import com.hsy.linemoney.modules.my.editinformation.EditMyInformationActivity;

/**
 * Created by Administrator on 2016/8/30.
 */
public class MyActionBar extends RelativeLayout implements IActionBar {
    protected View rootView;
    protected ImageView myEdit;
    private MainActivity activity;

    public MyActionBar(Context context) {
        super(context);
        init(context);
    }

    public MyActionBar(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public MyActionBar(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    public void setActivity(MainActivity activity) {
        this.activity = activity;
    }


    private void init(Context context) {
        addView(inflate(context, R.layout.actionbar_my, null), new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
        initView(this);
    }

    private void initView(View rootView) {
        myEdit = (ImageView) rootView.findViewById(R.id.my_edit);
        myEdit.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                activity.startActivity(EditMyInformationActivity.class);
            }
        });
        myEdit.setVisibility(GONE);
    }
}
